#include <cstdio>
#include <vector>
#include <cstring>
#define MAXN 510
#define INF 1 << 20
using namespace std;
int F, N, M, W;
int dp[MAXN];
struct edge {
    int u, v, c;
    edge(int _u, int _v, int _c): u(_u), v(_v), c(_c) {}
};
vector<edge> e;

void solve();
int main() {
    int f, t, c;
    scanf("%d", &F);
    while (F--) {
        scanf("%d %d %d", &N, &M, &W);
        e.clear();
        for (int i = 0; i < M; i++) {
            scanf("%d %d %d", &f, &t, &c);
            e.push_back(edge(f, t, c));
            e.push_back(edge(t, f, c));
        }
        for (int i = 0; i < W; i++) {
            scanf("%d %d %d", &f, &t, &c);
            e.push_back(edge(f, t, -c));
        }
        solve();
    }
}

void solve() {
    memset(dp, 0, sizeof dp);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < e.size(); j++) {
            edge es = e[j];
            if (dp[es.v] > dp[es.u] + es.c) {
                dp[es.v] = dp[es.u] + es.c;
                if (i == N - 1) {
                    printf("YES\n");
                    return;
                }
            }
        }
    }
    printf("NO\n");
    
}